﻿ModuleRouter = {
	moduleJs : {
		"overview" : "../javascripts/modules/overview/overview-ht.js",
		"company" : "../javascripts/modules/dataManage/company-ht.js",
		"department" : "../javascripts/modules/dataManage/department-ht.js",
		"analysis" : "../javascripts/modules/analysis/analysis-ht.js",
		"visitorOrder" : "../javascripts/modules/visitorManage/visitor_order-ht.js",
		"visitorCount" : "../javascripts/modules/visitorManage/visitor_count-ht.js",
		"visitorRecord" : "../javascripts/modules/visitorManage/visitor_record-ht.js",
		"attnSetting" : "../javascripts/modules/attnManage/attnSetting-ht.js",
		"holidayManage":"../javascripts/modules/attnManage/holidayManage-ht.js",
		"attnStatistics":"../javascripts/modules/attnManage/attnStatistics-ht.js",
		"attnHistory":"../javascripts/modules/attnManage/attnHistory-ht.js",
		"dataManage" : "../javascripts/modules/systemManage/data_manage-ht.js",
		"accessManage" : "../javascripts/modules/systemManage/access_manage-ht.js",
		"roleManage" : "../javascripts/modules/systemManage/role_manage-ht.js",
    },
	moduleTemplate : {
		"overview":"../page/overview/overview.html",
		"company":"../page/dataManage/company.html",
		"department":"../page/dataManage/department.html",
		"analysis":"../page/analysis/analysis.html",
		"visitorOrder":"../page/visitorManage/visitor_order.html",
		"visitorCount":"../page/visitorManage/visitor_count.html",
		"visitorRecord":"../page/visitorManage/visitor_record.html",
		"attnSetting":"../page/attnManage/attnSetting.html",
		"holidayManage":"../page/attnManage/holidayManage.html",
		"attnStatistics":"../page/attnManage/attnStatistics.html",
		"attnHistory":"../page/attnManage/attnHistory.html",
		"dataManage":"../page/systemManage/data_manage.html",
		"accessManage":"../page/systemManage/access_manage.html",
		"roleManage":"../page/systemManage/role_manage.html"
	},
	init : function(module,callback){
		if(Util.isEmpty(module)){ return false; }
		var me = this,
			index = window.location.href.indexOf('index.html'),
			host = (index>0)?window.location.href.slice(0,index):window.location.href.slice(0,index)+"/";
		$.get(host + me.moduleTemplate[module]+"?"+new Date().getTime(),function(data){
			$("#tempContainer").html(data);
			$.getScript(host + me.moduleJs[module],function(){
				$(".main_body").attr("data-now",module);
				switch (module){
					case "overview":
						overview.init();
						break;
					case "company":
						company.init();
						break;
					case "department":
						department.init();
						break;
					case "visitorOrder":
						visitorOrder.init();
						break;
					case "visitorCount":
						visitorCount.init();
						break;
					case "visitorRecord":
						visitorRecord.init();
						break;
					case "dataManage":
						dataManage.init();
						break;
					case "accessManage":
						accessManage.init();
						break;
					case "roleManage":
						roleManage.init();
						break;
					case "attnSetting":
						attnSetting.init();
						break;
					case "holidayManage":
						holidayManage.init();
						break;
					case "attnStatistics":
						attnStatistics.init();
						break;
					case "attnHistory":
						attnhistory.init();
						break;
  				}
				!Util.isEmpty(callback)?callback():"";
			});
		});
	},
	loadLeftTemp: function (module) {
		var _this = this;
		if (Util.isEmpty(module)) { return false; }
		var menu = {
			"dataManage": {
				"xxgl":{name: "company", text: "公司信息"},
				"bmxx":{name: "department", text: "部门信息"}
			},
			"visitorManage": {
				"fkyy": {name: "visitorOrder", text: "访客预约"},
				"fktj": {name: "visitorCount", text: "访客统计"},
				"fkjl": {name: "visitorRecord", text: "访客记录"}
			},
			"attnManage": {
				"kqsz": {name: "attnSetting", text: "考勤设置"},
				"jjrgl": {name: "holidayManage", text: "节假日管理"},
				"kqtj": {name: "attnStatistics", text: "考勤统计"},
				"lsjl": {name: "attnHistory", text: "历史记录"}
			},
			"systemManage": {
				"sjgl": {name: "dataManage", text: "数据管理"},
				"qxgl": {name: "accessManage", text: "权限管理"},
				"jsgl": {name: "roleManage", text: "角色管理"}
			}
		};
		var menuInfo = JSON.parse(sessionStorage.getItem("menuInfo"));
		var userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
		var temp = Util.template($("#menu-template").html(), {menu: menu[module],menuInfo:menuInfo,userInfo:userInfo});
		$(".main_body").html(temp);
		/***
		 * 该大模块载入时，选择初始载入的子模块
		 */
		//大模块载入时，默认进入第一个子模块，开发时可以注掉此行并解注下一行
		$(".common-menu-box >a:first-child").trigger("click");
		//_this.init("company");
	}
};
/*



* */